home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / Kludges.subproj / EPSWriting.m < prev    next >
Encoding:
Text File  |  1994-07-21  |  1.6 KB  |  51 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //    FILENAME:    EPSWriting.m
  3. //    SUMMARY:    Implementation of a EPSWriting category to NXImage
  4. //    SUPERCLASS:    Object:NXImage(EPSWriting)
  5. //    INTERFACE:    None
  6. //    AUTHOR:        Rohit Khare (_EPSWritingImageView by Sharon Zahkour of NeXT)
  7. //    COPYRIGHT:    (c) 1994 California Institure of Technology, eText Project
  8. ///////////////////////////////////////////////////////////////////////////////
  9. //  IMPLEMENTATION COMMENTS
  10. //        If there exists an NXEPSImageRep, write out the EPS code.
  11. //        If not, create an offscreen window, draw the NXImage and save as EPS.
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //    HISTORY
  14. //    07/16/94:    Created. Derived from TIFFtoEPS.app.
  15. ///////////////////////////////////////////////////////////////////////////////
  16.  
  17. #import <appkit/appkit.h>
  18. #import "EPSWriting.h"
  19.  
  20. @implementation NXImage (EPSWriting)
  21. - writeEPS:(NXStream *)stream
  22. {
  23.     id    repList;
  24.     int    i,j;
  25.     id theRep=nil;
  26.     char *theCode;
  27.     int    len;
  28.  
  29.     // choose find EPSRep if possible.
  30.     repList = [self representationList];
  31.     theRep = nil;
  32.     i = [repList count];
  33.     for(j=0; j<i; j++){
  34.     if ([[repList objectAt:j] isKindOf:[NXEPSImageRep class]])
  35.         theRep = [repList objectAt:j];
  36.     }        
  37.     if (theRep && [theRep isKindOf:[NXEPSImageRep class]]) {            
  38.         [theRep getEPS:&theCode length:&len];
  39.         NXWrite(stream, theCode, len);
  40.     } else {
  41.         // we need to convert a bitmap to EPS.
  42.         NXRect     rect;
  43.         id        iv;
  44.         
  45.         iv = [[_FormatWritingImageView new] useImage:self];
  46.         [iv getFrame:&rect];
  47.         [iv copyPSCodeInside:&rect to:stream]; 
  48.     }
  49.     return self;
  50. }
  51. @end